import { post, remove, get, put } from './api'
// import { read } from '../store/modules/init.js'

//获取职能列表
export const getDutyList = (args={}) => {
    const url = '/usermgt/func';
    const body = {
        method: 'funcList',
        args: JSON.stringify(args)
    };
    return post(url, body)
};

//获取单个职能
export const getDutyInfo = (id) => {
    const url = `/usermgt/func/${id}`;
    return get(url)
};

//获取单个职能
export const getDutyDetail = (id) => {
    const url = `/usermgt/func/rs/${id}`;
    return get(url)
};
//添加职能
export const addDuty = (args) => {
    const url = `/usermgt/func`;
    const body = {
        method: 'addFunc',
        args: JSON.stringify(args)
    };
    return post(url, body)
};
//校验职能名称
export const validDuty = (args) => {
    const url = `/usermgt/func`;
    const body = {
        method: 'validFunc',
        args: JSON.stringify(args)
    };
    return post(url, body)
};

//添加职能数据权限
export const addDutyPermission = (id, args) => {
    const url = `/usermgt/func/${id}`;
    const body = {
        method: 'addFunctionDataPermission',
        args: JSON.stringify(args)
    };
    return put(url, body)
};

//复制职能
export const copyDuty = (id, args) => {
    const url = `/usermgt/func/${id}`;
    const body = {
        method: 'copyFunc',
        args: JSON.stringify(args)
    };
    return post(url, body)
};

//修改职能信息
export const updateDuty = (id, args) => {
    const url = `/usermgt/func/${id}`;
    const body = {
        method: 'updateFunc',
        args: JSON.stringify(args)
    };
    return put(url, body)
};

//删除职能
export const deleteDuty = (id, args) => {
    const url = `/usermgt/func/${id}`;
    return remove(url)
};


//获取数据权限
export const datapermission = () => {
    const url = `/usermgt/datapermission`;
    return post(url,{})
};